var libs = require('libs/libs');
var List = require('widgets/listView/list')

var Service = React.createClass({
    getInitialState:function(){
		return {
            serviceData: false
		}
	},
    componentWillMount: function(){
        if (this.props.data){
            this.setState({
                serviceData: this.props.data
            })
        }
    },

    showonlineWillMount: function(){
        var showonline = this.state.serviceData,
            showonlineImg,
            showonlineName,
            servList=[];
        if(showonline){
            showonlineName = showonline.providerName?showonline.providerName:'';
            if(showonline.imgFileList){         //判断小区是否有图片
                if(showonline.imgFileList.length){
                    showonlineImg = showonline.imgFileList[0].extUrl
                }
            }else{
                showonlineImg = ''
            }

            if (showonline.serviceItemsList){
                var _list = showonline.serviceItemsList;
                _list.map(function(item){
                    servList.push({
                        className: 'xxx',
                        title: <a>{item.dicName}</a>

                    })
                })
            }

            return(
                <li className="dCy_branches">
                    <div className="dCy_pic">
                        <img src={showonlineImg} />
                    </div>
                    <div className="dCy_b_com">
                        <em>{showonlineName}</em>
                        <List listClass="default_label_branches" data={servList}/>
                    </div>
                </li>
            )
        }
    },

    render: function(){
        var s_list = this.showonlineWillMount()
        return s_list
    }
})

module.exports = Service
